global NoQuiz, timer, loop, rate, Tries, Energy, Angle
cursor(4)
set loop to 0
set Energy to "0"
set Angle to "45"
BSetup(20, 20)
BStart()
go("Game")
set Tries to 0
set the movieTime of sprite 4 to 0
set the movieRate of sprite 4 to rate
set NoQuiz to 1
set timer to 1
cursor(-1)
end
on stop
global timer, NoQuiz, QuizWaiting
set timer to 0
repeat with count = 6 to 8
set the puppet of sprite count to 0
end repeat
set the visible of sprite 4 to 1
BStop()
BSuspend(29, 29)
BSuspend(20, 20)
go(2)
set NoQuiz to 0
if QuizWaiting = 1 then
PopQuiz()
end if
end
on EndGame
global timer, TimeSec, Tries, BoxUp, rate
set timer to 0
put "Congratulations! The chemicals reacted! You took " & WriteTime(4, rate) & " and " & Tries & " tries. Your score is " & score() & "." into field "MsgBox"
end
on TimeUp
global timer, TimeSec, BoxUp
set timer to 0
set the movieRate of sprite 4 to 0
set TimeSec to 360
puppetSound("Game Over")
put "Time Up! Because you didn't get the chemicals to react, your score is 0." into field "MsgBox"
set BoxUp to 1
go("BoxUp")
end
on score
global Difficulty, Tries, rate, AtomReacting
set GameScore to 10000 - (Tries * 1000) - (Difficulty / 2 * (time(4, rate) * 10))
if GameScore < 0 then
set GameScore to 0
end if
if GameScore > AtomReacting then
set AtomReacting to GameScore
end if
ScoreDisplay()
return GameScore
end
on BoxUp
if (the clickOn >= 27) and (the clickOn <= 29) then
pass()
else
if the mouseDown = 1 then
beep()
end if
dontPassEvent()
end if
end
on KeyCheck
if the key = RETURN then
if (the frame >= 13) and (the frame <= 14) then
OKButton()
else
stop()
end if
else
pass()
end if
end
on OKButton
global result
BSuspend(29, 29)
if value(result) = 1 then
stop()
exit
end if
EndTest()
end
on ScientistScreen
cursor(4)
go(1, the pathName & "POLANY_S.DIR")
cursor(4)
end
on idle
global timer, ButtonsActive
if (timer <> 0) and (the frame > 6) and (the frame < 10) then
if (the movieRate of sprite 4 = 0) or (the movieTime of sprite 4 = 21600) then
TimeUp()
end if
end if
if (the frame > 6) and (the frame < 10) then
if ButtonsActive = 1 then
CheckHilite(20, 20)
end if
end if
PopIdle()
GameIdle()
end
on Test
global ReadData, DataFile, A1X, A1Y, A2X, A2Y, A3X, A3Y, result, ContactPt, EndPt, loop, CentreX, CentreY, point, Tries, Energy, Angle, Sep
cursor(4)
set Tries to Tries + 1
set the puppet of sprite 6 to 1
set the puppet of sprite 7 to 1
set the puppet of sprite 8 to 1
set DataFile to Energy & "-" & Angle
put DataFile
set A1X to EMPTY
set A1Y to EMPTY
set A2X to EMPTY
set A2Y to EMPTY
set A3X to EMPTY
set A3Y to EMPTY
set result to line 6 of the text of cast DataFile
if value(result) = 0 then
put "No reaction. Please try again." into field "MsgBox"
end if
if value(result) = 1 then
put "Congratulations! The chemicals reacted!" into field "MsgBox"
end if
if value(result) = 2 then
put "No reaction, only hydrogen atoms were exchanged. Please try again." into field "MsgBox"
end if
set ContactPt to line 7 of the text of cast DataFile
repeat with Counter = 1 to 150
set Temp to line Counter + 7 of the text of cast DataFile
put word 1 of Temp into line Counter of A1X
put word 2 of Temp into line Counter of A1Y
put word 3 of Temp into line Counter of A2X
put word 4 of Temp into line Counter of A2Y
put word 5 of Temp into line Counter of A3X
put word 6 of Temp into line Counter of A3Y
end repeat
set EndPt to 0
repeat with Counter = 1 to 150
if (line Counter of A1X = EMPTY) and (EndPt = 0) then
set EndPt to Counter - 1
end if
end repeat
set CentreX to 640 / 2
set CentreY to 480 / 2
set loop to 0
puppetTempo(8 * (value(Energy) + 1))
go("React")
end
on EndTest
global result, ButtonsActive
set ButtonsActive to 1
go("Game2")
end
on AfterTest
global Tries, result
if value(result) = 1 then
EndGame()
end if
set the locH of sprite 6 to -100
set the locH of sprite 7 to -100
set the locH of sprite 8 to -100
go("AfterReact")
if value(result) = 1 then
puppetSound("Win")
end if
end
on Lock
global Energy, Angle, X, Y, z
if the locH of sprite 12 < 171 then
set the locH of sprite 12 to 140
set Energy to "0"
end if
if (the locH of sprite 12 > 170) and (the locH of sprite 12 < 232) then
set the locH of sprite 12 to 201
set Energy to "1"
end if
if (the locH of sprite 12 > 231) and (the locH of sprite 12 < 293) then
set the locH of sprite 12 to 262
set Energy to "2"
end if
if (the locH of sprite 12 > 292) and (the locH of sprite 12 < 354) then
set the locH of sprite 12 to 323
set Energy to "3"
end if
if (the locH of sprite 12 > 353) and (the locH of sprite 12 < 415) then
set the locH of sprite 12 to 384
set Energy to "4"
end if
if (the locH of sprite 12 > 414) and (the locH of sprite 12 < 476) then
set the locH of sprite 12 to 445
set Energy to "5"
end if
if the locH of sprite 12 > 475 then
set the locH of sprite 12 to 506
set Energy to "6"
end if
if the locH of sprite 13 < 159 then
set the locH of sprite 13 to 138
set Angle to "00"
end if
if (the locH of sprite 13 > 158) and (the locH of sprite 13 < 201) then
set the locH of sprite 13 to 179
set Angle to "05"
end if
if (the locH of sprite 13 > 200) and (the locH of sprite 13 < 242) then
set the locH of sprite 13 to 220
set Angle to "10"
end if
if (the locH of sprite 13 > 241) and (the locH of sprite 13 < 283) then
set the locH of sprite 13 to 261
set Angle to "15"
end if
if (the locH of sprite 13 > 282) and (the locH of sprite 13 < 324) then
set the locH of sprite 13 to 302
set Angle to "20"
end if
if (the locH of sprite 13 > 323) and (the locH of sprite 13 < 365) then
set the locH of sprite 13 to 343
set Angle to "25"
end if
if (the locH of sprite 13 > 364) and (the locH of sprite 13 < 406) then
set the locH of sprite 13 to 384
set Angle to "30"
end if
if (the locH of sprite 13 > 405) and (the locH of sprite 13 < 447) then
set the locH of sprite 13 to 425
set Angle to "35"
end if
if (the locH of sprite 13 > 446) and (the locH of sprite 13 < 488) then
set the locH of sprite 13 to 466
set Angle to "40"
end if
if the locH of sprite 13 > 487 then
set the locH of sprite 13 to 507
set Angle to "45"
end if
end
on HideInfoComplete
global timer, rate
if (the frame > 6) and (the frame < 17) then
set the movieRate of sprite 4 to rate
set timer to 1
end if
end
on ShowInfoPrep
global timer
if the frame > 6 then
set timer to 0
set the movieRate of sprite 4 to 0
end if
return 1
end
on SetupData
if the machineType = 256 then
set Sep to "/"
else
set Sep to ":"
end if
set castCount to 1
repeat with Energy = 0 to 6
repeat with AngleCount = 0 to 9
set Angle to AngleCount * 5
if Angle = 0 then
set Angle to "00"
end if
if Angle = 5 then
set Angle to "05"
end if
set name to Energy & "-" & Angle
set fileName to the pathName & "ATOMDATA" & Sep & name & ".DAT"
set ReadData to FileIO(mnew, "read", fileName)
put name
repeat with count = 1 to 150
put ReadData(mReadLine) into line count of field castCount of castLib 3
end repeat
set the name of member castCount of castLib 3 to name